<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="b1w1nn1ng.crossf1t.gui.*"%>
<%@page import="b1w1nn1ng.crossf1t.business.*"%>
<%@page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>

		<title> Settings Report Page </title>
		<jsp:include page="/detectBrowser.jsp" />	

		<title>Weekly Report</title>
	<link rel="stylesheet" type="text/css" href="/crossfit/css/general.css" />
	<jsp:include page="/detectBrowser.jsp" />	
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
		<script type="text/javascript" src="highcharts.js"></script>
		<script type="text/javascript" src="gray.js"></script>
		<%  
		User user = (User) session.getAttribute("user");
		session.setAttribute("user", user);
		/*User user;
	
	if (session.getAttribute("user") == null) {
		String username = request.getParameter("username");
		user = User.getUserByUsername(username);
		session.setAttribute("user", user); 
	}
	else {
		user = (User) session.getAttribute("user");
	}*/
	//System.out.println(user.getId());
	String[] temp = Graph.getOptions(user.getId());
	//System.out.println(temp [0] + " " + temp [1]);
%>

	<style type="text/css"><!--
		ul.specials li p { color:red; }
		ul.specials li span { color:green; }
		--></style>

	</head>
	<body>
		<div id="container">

		<jsp:include page="/navbar.jsp" />	
		<h1> Report Settings </h1> <hr />	
			<table id="settingsTable" style="padding-top:80px; width:100%;">
				<tr>
					<td><a href="settings.jsp"><img
					src="/crossfit/img/blackbutton_settings_accountSettings.png" alt="Account Settings" /> </a></td>
					<td><a href="settingsReport.jsp"><img 
					src="/crossfit/img/blackbutton_settings_reportSettings.png" alt="Report Settings" /> </a></td>
				</tr>
				<tr>
					<td style="margin-right: 50px; font-size:80%;">Account Settings</td>
					<td style="margin-right: 30px; font-size:80%;">Report Settings</td>
				</tr>
			</table>
			
			<br /><br /><br /><br />
		
		<form method="get" action="/crossfit/user/home.jsp" style="margin-top: -80px">
			<table id="report">
				<tr>
					<td style="font-size: 200%;">Send Reports</td>
					<td> &nbsp; <input type="checkbox" value="Save Changes" id = "reportCheckBox" style="width: 50px; height:75px;"/> </td>
				</tr>
				<tr>
					<td colspan=2> <input type="submit" value="Save Changes" style="font-size:36px;" /> </td>
				</tr>
			</table>
		</form>
		<table width = "400" height = "150" align = "center">
	<tr>
	<td><a href="../displayWorkout.jsp?date=05/02/2011">View Your workouts for the Past Week</a> </td>
	<td><img src="../img/crossfit-logo.jpg" width = "300" height= "100" align = "right"/></td>
	</tr>
	
	</table>
	<table  width = "400" height = "200" align = "center">
	<tr>
		<td><%
		if(user.getGoals().size() == 0)
			out.println("You do not currently have any goals set.<br />");
		else {
			out.println("<hd> Goals </hd>");
			out.println("<ul class = \"specials\">");
			int i =0;
			for(String g : user.getGoals()) {
				if(i%2==0)
				out.println("<li><p>"+g +"</p></li>\n");
				else
					out.println("<li><span>"+g+"</span></li>\n");
				i++;
				}
				out.println("</ul>");
		}
				
				%></td>
	</tr>
	<tr>
		<td> <div id = "container2"></div></td>
	</tr>
</table> 
</div>
</body>
<script language ='JavaScript' TYPE="text/javascript">
	var chart;
$(document).ready(function() {
	var options = {
		chart: {
			renderTo: 'container2',
			defaultSeriesType: 'line',
			zoomType: 'x'
			},
		title: {
			text: 'Weight For The Past Week'
			},
		subtitle: {
			text: ''
			},
		xAxis: {
			type: 'datetime',
			maxZoom: 7*24*3600000,
			title:{
				text: 'Day'
			},
	},
		yAxis: {
			startOnTick:false,
			title: {
				text: 'Weight(lbs)'
				}
			},
		tooltip: {
			enabled: false,
			formatter: function() {
			return '<b>'+ this.series.name +'</b><br/>'+
								this.x +': '+ this.y +'°C';
			}
			},
		plotOptions: {
			line: {
			  dataLabels: {
			    enabled: true
				      },
			  enableMouseTracking: false
			       }
			},
		series: [{
			pointInterval:24*3600*1000,
			pointStart:Date.UTC(<%=temp[0]%>),
			name: '<%=((String)user.getFirstName())%>',
			data: [<%=temp[1]%>]
			}]
	}
	chart = new Highcharts.Chart(options);
	//alert(nothing);

});
</script>
		</div>
		</body>

	
</html>

